#!/bin/bash

CUR_DIR=`pwd`
if test -z $JAVA_HOME; then
  echo "JAVA_HOME is not set"
  exit 1
fi
INC_JAVA=$JAVA_HOME/include
INC_GLIB=/usr/include/glib-2.0
INC_PBC=$CUR_DIR/pbc-0.5.12/include
INC_CELIA=../libcelia
INC_KPABE=../libkpabe

if test ! -d $INC_GLIB; then
  echo "Cannot find Glib"
  exit 1
fi

if test ! -d $INC_PBC; then
  echo "Cannot find PBC library"
  exit 1
fi

cd $CUR_DIR/src
g++ -c -fPIC -I $INC_JAVA -I $INC_JAVA/linux -I $INC_GLIB -I $INC_PBC -I $INC_CELIA -I
$INC_KPABE kpabe_owner.cc kpabe_user.cc kpabe_cloud.cc test.cc

g++ -shared -o libproxyKPAbe.so *.o ../libcelia/*.o ../libkpabe/common.o
../libkpabe/policy_lang.o -lpbc -lglib-2.0 -lgmp -lcrypto 

#g++ -c -fPIC -I /home/ttadinh/Downloads/jdk1.6.0_27/include -I /home/ttadinh/Downloads/jdk1.6.0_27/include/linux -I /usr/include/glib-2.0 -I /home/ttadinh/Downloads/ABETest/pbc-0.5.12/include -I ../libkpabe -I ../libcelia kpabe_owner.cc kpabe_user.cc kpabe_cloud.cc test.cc

#g++ -o libproxyKPAbe.so -shared kpabe_owner.o kpabe_user.o kpabe_cloud.o ../libcelia/*.o ../libkpabe/common.o ../libkpabe/policy_lang.o -lpbc -lglib-2.0 -lgmp -lcrypto
